<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>添加背景图然后居中对齐</title>
  <style>
    .red2 {
      width: 100px;
      height: 200px;
      border: 1px solid red
    }
  </style>
</head>

<body>
  <div class="red2">

  </div>
</body>

</html>